﻿// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

using Furion.EventBus;

namespace Abc.Core.EventBus.Subscribers;
/// <summary>
/// 更新订单支付信息 订阅
/// </summary>
public class EmailEventSubscriber : IEventSubscriber, ISingleton
{
    private readonly ILogger<EmailEventSubscriber> _logger;
    private readonly IServiceProvider _service;

    public EmailEventSubscriber(IServiceProvider services
        , ILogger<EmailEventSubscriber> logger)
    {
        _service = services;
        _logger = logger;
    }
    /// <summary>
    /// 发送邮件
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    //[EventSubscribe("ToDo:SendEmail_ToDo")]
    [EventSubscribe(EventSubscribeType.系统邮件)]
    public async Task Email_ByOrderId_ToDo(EventHandlerExecutingContext context)
    {
        //var todo = context.Source;

        ////把obj转换为  SysEventSourceStorer
        //var pess = (ProcessingEventSourceStorerDto)todo.Payload;

        //await EventBusSubscriberExec.InvokeAsync(async () =>
        //{
        //    //解析传递的数据
        //    var clay = Clay.Parse(pess.EventSourceStorer.Payload);

        //    using var scope = _service.CreateScope();
        //    var _emailSendService = scope.ServiceProvider.GetRequiredService<IEmailSendService>();
        //    //邮件发送

        //}, pess);
        await Task.CompletedTask;
    }


}
